
package com.insigma.business.qrcode.soldier.service.impl;


import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.common.util.AdminAreaCodeUtils;
import com.insigma.business.qrcode.soldier.dao.SoldierPetitionInfoDao;
import com.insigma.business.qrcode.soldier.dto.SequenceNameConstant;
import com.insigma.business.qrcode.soldier.entity.DataStatsCDO;
import com.insigma.business.qrcode.soldier.entity.SoldierPetitionInfoDO;
import com.insigma.business.qrcode.soldier.request.SoldierPetitionInfoBSearcher;
import com.insigma.business.qrcode.soldier.service.SoldierPetitionInfoService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("soldierPetitionInfoService")
public class SoldierPetitionInfoServiceImpl implements SoldierPetitionInfoService {

    @Autowired(required = false)
    private SoldierPetitionInfoDao soldierPetitionInfoDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;

    
    @Override
    public List<SoldierPetitionInfoDO> search(final SoldierPetitionInfoBSearcher searcher) {
        if (Strings.isNotBlank(searcher.getAdminAreaCode())) {
            searcher.setAdminAreaCode(AdminAreaCodeUtils.getCutdAreaCode(searcher.getAdminAreaCode()));
        }
        return soldierPetitionInfoDao.search(searcher);
    }
   
    @Override
    public SoldierPetitionInfoDO get(final String id){
        return soldierPetitionInfoDao.get(id);
    }

    
    @Override
    public Integer insert(final SoldierPetitionInfoDO soldierPetitionInfoDO){
        soldierPetitionInfoDO.setId(sequenceGenerator.genKey(SequenceNameConstant.SOLDIER_PETITION_INFO_ID));
        return soldierPetitionInfoDao.insert(soldierPetitionInfoDO);
    }

    
    @Override
    public Integer update(final SoldierPetitionInfoDO soldierPetitionInfoDO){
        return soldierPetitionInfoDao.update(soldierPetitionInfoDO);
    }

    
    @Override
    public Integer delete(final String id, final String modifierType, final String modifierId){
        return soldierPetitionInfoDao.delete(id,modifierType,modifierId);
    }

    @Override
    public List<SoldierPetitionInfoDO> listByIdCardNo(String idCardNo) {
        return soldierPetitionInfoDao.listByIdCardNo(idCardNo);
    }

    @Override
    public Integer countByArea(String adminAreaCode) {
        return soldierPetitionInfoDao.countByArea(AdminAreaCodeUtils.getCutdAreaCode(adminAreaCode));
    }

    @Override
    public List<DataStatsCDO> groupTypeMap(String adminAreaCode) {
        return soldierPetitionInfoDao.groupTypeMap(AdminAreaCodeUtils.getCutdAreaCode(adminAreaCode));
    }

    @Override
    public Integer countByBjbz(String adminAreaCode) {
        return soldierPetitionInfoDao.countByBjbz(adminAreaCode);
    }

    @Override
    public SoldierPetitionInfoDO getByStoreId(String storeid) {
        return soldierPetitionInfoDao.getByStoreId(storeid);
    }

    @Override
    public List<DataStatsCDO> groupTypeMapAndDetail(String adminAreaCode, String detail) {
        return soldierPetitionInfoDao.groupTypeMapAndDetail(adminAreaCode, detail);
    }

}
